﻿using System;
using System.Collections.Generic;
using System.Text;

namespace BaseSimpleAPI
{
    public class StringResult : IActionResult
    {
        private string _str = null;

        public StringResult(string str)
        {
            _str = str;
        }

        /// <summary>
        /// 获取响应数据
        /// </summary>
        /// <returns></returns>
        public byte[] GetRespondData()
        {
            // 修剪多余的响应头
            ResponseHeaderHelper.GetInstance().TrimResponseHeader("ContentType");

            // 补全响应头
            ResponseHeaderHelper.GetInstance().CompletionResponseHeader(new Dictionary<string, string>
            {
                { "ResponseEncoding", "UTF-8" },
                { "ContentType", "text/string" },
            });

            return ActionResultHelper.GetResponseData(_str);
        }
    }
}
